From 517c3c9db2ce5d9dbf41cca97c48a33543242431 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 16 Aug 2004 18:38:55 +0000 Subject: [PATCH] Doc update. 2004-08-16 Matthias Clasen * gtk/gtkwidget.c (gtk_widget_render_icon): Doc update. * gtk/gtkiconfactory.c (render_icon_name_pixbuf): When the size is -1, use the available size closest to 48. (#150147) * gtk/gtkicontheme.c (gtk_icon_theme_get_icon_sizes): Actually return a pointer to the beginning of the sizes array, not the end. --- ChangeLog | 12 +++++++++++- ChangeLog.pre-2-10 | 12 +++++++++++- ChangeLog.pre-2-6 | 12 +++++++++++- ChangeLog.pre-2-8 | 12 +++++++++++- gtk/gtkiconfactory.c | 42 ++++++++++++++++++++++++++++++++++++++++-- gtk/gtkicontheme.c | 6 +++--- gtk/gtkwidget.c | 3 ++- 7 files changed, 89 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index f5a29422da..dd93bf5e3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +<<<<<<< ChangeLog +2004-08-16 Matthias Clasen + + * gtk/gtkwidget.c (gtk_widget_render_icon): Doc update. + + * gtk/gtkiconfactory.c (render_icon_name_pixbuf): When the size is -1, + use the available size closest to 48. (#150147) + + * gtk/gtkicontheme.c (gtk_icon_theme_get_icon_sizes): Actually return + a pointer to the beginning of the sizes array, not the end. + 2004-08-16 Morten Welinder * gtk/gtksequence.c (_gtk_sequence_set): Fix C99ism. @@ -8,7 +19,6 @@ Mon Aug 16 01:35:25 2004 Matthias Clasen - Fix #150125: * gtk/gtkcombobox.[hc]: Add a ::focus-on-click property and change the default behaviour to focus on click. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f5a29422da..dd93bf5e3b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,14 @@ +<<<<<<< ChangeLog +2004-08-16 Matthias Clasen + + * gtk/gtkwidget.c (gtk_widget_render_icon): Doc update. + + * gtk/gtkiconfactory.c (render_icon_name_pixbuf): When the size is -1, + use the available size closest to 48. (#150147) + + * gtk/gtkicontheme.c (gtk_icon_theme_get_icon_sizes): Actually return + a pointer to the beginning of the sizes array, not the end. + 2004-08-16 Morten Welinder * gtk/gtksequence.c (_gtk_sequence_set): Fix C99ism. @@ -8,7 +19,6 @@ Mon Aug 16 01:35:25 2004 Matthias Clasen - Fix #150125: * gtk/gtkcombobox.[hc]: Add a ::focus-on-click property and change the default behaviour to focus on click. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index f5a29422da..dd93bf5e3b 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,14 @@ +<<<<<<< ChangeLog +2004-08-16 Matthias Clasen + + * gtk/gtkwidget.c (gtk_widget_render_icon): Doc update. + + * gtk/gtkiconfactory.c (render_icon_name_pixbuf): When the size is -1, + use the available size closest to 48. (#150147) + + * gtk/gtkicontheme.c (gtk_icon_theme_get_icon_sizes): Actually return + a pointer to the beginning of the sizes array, not the end. + 2004-08-16 Morten Welinder * gtk/gtksequence.c (_gtk_sequence_set): Fix C99ism. @@ -8,7 +19,6 @@ Mon Aug 16 01:35:25 2004 Matthias Clasen - Fix #150125: * gtk/gtkcombobox.[hc]: Add a ::focus-on-click property and change the default behaviour to focus on click. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index f5a29422da..dd93bf5e3b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,14 @@ +<<<<<<< ChangeLog +2004-08-16 Matthias Clasen + + * gtk/gtkwidget.c (gtk_widget_render_icon): Doc update. + + * gtk/gtkiconfactory.c (render_icon_name_pixbuf): When the size is -1, + use the available size closest to 48. (#150147) + + * gtk/gtkicontheme.c (gtk_icon_theme_get_icon_sizes): Actually return + a pointer to the beginning of the sizes array, not the end. + 2004-08-16 Morten Welinder * gtk/gtksequence.c (_gtk_sequence_set): Fix C99ism. @@ -8,7 +19,6 @@ Mon Aug 16 01:35:25 2004 Matthias Clasen - Fix #150125: * gtk/gtkcombobox.[hc]: Add a ::focus-on-click property and change the default behaviour to focus on click. diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c index b3915571c1..5a93420c1c 100644 --- a/gtk/gtkiconfactory.c +++ b/gtk/gtkiconfactory.c @@ -1649,6 +1649,7 @@ render_icon_name_pixbuf (GtkIconSource *icon_source, GtkIconTheme *icon_theme; GtkSettings *settings; gint width, height, pixel_size; + gint *sizes, *s, dist; GError *error = NULL; if (widget && gtk_widget_has_screen (widget)) @@ -1667,8 +1668,45 @@ render_icon_name_pixbuf (GtkIconSource *icon_source, if (!gtk_icon_size_lookup_for_settings (settings, size, &width, &height)) { - g_warning ("Invalid icon size %d\n", size); - width = height = 24; + if (size == -1) + { + /* Find an available size close to 48 + */ + sizes = gtk_icon_theme_get_icon_sizes (icon_theme, icon_source->source.icon_name); + dist = 1000; + width = height = 48; + for (s = sizes; *s; s++) + { + if (*s == -1) + { + width = height = 48; + break; + } + if (*s < 48) + { + if (48 - *s < dist) + { + width = height = *s; + dist = 48 - *s; + } + } + else + { + if (*s - 48 < dist) + { + width = height = *s; + dist = *s - 48; + } + } + } + + g_free (sizes); + } + else + { + g_warning ("Invalid icon size %d\n", size); + width = height = 24; + } } pixel_size = MIN (width, height); diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index 2f1f43f7fe..b8db2b6402 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -1331,7 +1331,7 @@ gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme, { GList *l, *d; GHashTable *sizes; - gint *result; + gint *result, *r; guint suffix; GtkIconThemePrivate *priv; @@ -1362,9 +1362,9 @@ gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme, } } - result = g_new0 (gint, g_hash_table_size (sizes) + 1); + r = result = g_new0 (gint, g_hash_table_size (sizes) + 1); - g_hash_table_foreach (sizes, add_size, &result); + g_hash_table_foreach (sizes, add_size, &r); g_hash_table_destroy (sizes); return result; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 7a88f59785..58696d247d 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5041,7 +5041,8 @@ gtk_widget_create_pango_layout (GtkWidget *widget, * @widget: a #GtkWidget * @stock_id: a stock ID * @size: a stock size. A size of (GtkIconSize)-1 means render at - the size of the source and don't scale. + * the size of the source and don't scale (if there are multiple + * source sizes, GTK+ picks one of the available sizes). * @detail: render detail to pass to theme engine * * A convenience function that uses the theme engine and RC file -- 2.30.2